package com.qyer.search.model.lastminute;

import java.util.*;
/**
 * Created by tangzheng on 16/7/18.
 */
public class VSKU extends SKU implements Comparable<VSKU>{

  protected int id;
  protected int type1;
  protected int type2;
  protected Set<Integer> stype;
  protected int marketInfo;
  protected int position;
  protected long price;
  protected long sale;

  public VSKU(int id, int type1, int type2, Set<Integer> stype, int marketInfo) {
    this.id = id;
    this.type1 = type1;
    this.type2 = type2;
    this.stype = stype;
    this.marketInfo = marketInfo;
  }

  public long getPrice() {
    return price;
  }

  public void setPrice(long price) {
    this.price = price;
  }

  public long getSale() {
    return sale;
  }

  public void setSale(long sale) {
    this.sale = sale;
  }

  public int getMarketInfo() {
    return marketInfo;
  }

  public void setMarketInfo(int marketInfo) {
    this.marketInfo = marketInfo;
  }

  @Override public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  @Override public int getType1() {
    return type1;
  }

  public void setType1(int type1) {
    this.type1 = type1;
  }

  @Override public int getType2() {
    return type2;
  }

  public void setType2(int type2) {
    this.type2 = type2;
  }

  public Set<Integer> getStype() {
    return stype;
  }

  public void setStype(Set<Integer> stype) {
    this.stype = stype;
  }

  public int getPosition() {
    return position;
  }

  public void setPosition(int position) {
    this.position = position;
  }

  @Override public boolean equals(Object o) {
    if (this == o)
      return true;
    if (o == null || getClass() != o.getClass())
      return false;

    VSKU vsku = (VSKU) o;

    if (id != vsku.id)
      return false;
    return type1 == vsku.type1;

  }

  @Override public int hashCode() {
    int result = id;
    result = 31 * result + type1;
    return result;
  }

  @Override public int compareTo(VSKU vsku) {
    return (this.marketInfo - vsku.getMarketInfo());
  }

  public RichSKU toSKU(){
    RichSKU richSKU = RichSKU.build();
    richSKU.setId(this.id);
    richSKU.setType1(type1);
    return richSKU;
  }

  @Override public String toString() {
    return "VSKU{" +
      "id=" + id +
      ", type1=" + type1 +
      ", type2=" + type2 +
      ", stype=" + stype +
      ", marketInfo=" + marketInfo +
      ", position=" + position +
      ", price=" + price +
      ", sale=" + sale +
      '}';
  }
}
